// This is the main DLL file.

#include "stdafx.h"

#include <iostream>
#include <sstream>
#include <string>

#include "Helper.h"
#include "WmiHelper.h"

using namespace std;
using namespace System::Text;

extern "C"
{
	int _stdcall Add(int a, int b);
	bool _stdcall FetchWmiDeviceList(int hardType, const char* propKey, const char* filter, char* buffer, int bufferSize);
}

int _stdcall Add(int a, int b)
{
	return a + b;
}

bool _stdcall FetchWmiDeviceList(int hardType, const char* propKey, const char* filter, char* buffer, int bufferSize)
{
	try
	{
		auto list = WmiHelper::HardwareInfoHelper::MulGetHardwareInfo((WmiHelper::HardwareEnum)hardType,
			gcnew String(propKey), gcnew String(filter));
		auto result = String::Join("\r\n", list);
		if (result->Length < bufferSize)
		{
			auto nativeStr = NetStringToString(result);
			cout << nativeStr << endl << "===========" << endl;
			strcpy(buffer, nativeStr.c_str());
			return true;
		}
		return false;
	}
	catch (Exception^ ex)
	{
		return false;
	}
}